import dotenv from 'dotenv';

// 环境变量指定
dotenv.config({ path: process.env.DOTENV_CONFIG_PATH || '.env' });

interface Config {
  port: number;
  env: string;
  db: {
    host: string;
    port: number;
    name: string;
    user: string;
    password: string;
  };
  jwtSecret: string;
}

const config: Config = {
  port: parseInt(process.env.PORT || '9002'),
  env: process.env.NODE_ENV || 'development',
  db: {
    host: process.env.DB_HOST || 'localhost',
    port: parseInt(process.env.DB_PORT || '27017'),
    name: process.env.DB_NAME || 'mydb',
    user: process.env.DB_USER || '',
    password: process.env.DB_PASSWORD || '',
  },
  jwtSecret: process.env.JWT_SECRET || 'secret',
};

export { config };